package com.flower.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.flower.common.annotation.Log;
import com.flower.common.core.controller.BaseController;
import com.flower.common.core.domain.AjaxResult;
import com.flower.common.enums.BusinessType;
import com.flower.system.domain.BizRecognition;
import com.flower.system.service.IBizRecognitionService;
import com.flower.common.utils.poi.ExcelUtil;
import com.flower.common.core.page.TableDataInfo;

/**
 * 花卉识别结果Controller
 * 
 * @author ruoyi
 * @date 2024-04-03
 */
@RestController
@RequestMapping("/system/recognition")
public class BizRecognitionController extends BaseController
{
    @Autowired
    private IBizRecognitionService bizRecognitionService;

    /**
     * 查询花卉识别结果列表
     */
    @PreAuthorize("@ss.hasPermi('system:recognition:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizRecognition bizRecognition)
    {
        startPage();
        List<BizRecognition> list = bizRecognitionService.selectBizRecognitionList(bizRecognition);
        return getDataTable(list);
    }

    /**
     * 导出花卉识别结果列表
     */
    @PreAuthorize("@ss.hasPermi('system:recognition:export')")
    @Log(title = "花卉识别结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizRecognition bizRecognition)
    {
        List<BizRecognition> list = bizRecognitionService.selectBizRecognitionList(bizRecognition);
        ExcelUtil<BizRecognition> util = new ExcelUtil<BizRecognition>(BizRecognition.class);
        util.exportExcel(response, list, "花卉识别结果数据");
    }

    /**
     * 获取花卉识别结果详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:recognition:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(bizRecognitionService.selectBizRecognitionById(id));
    }

    /**
     * 新增花卉识别结果
     */
    @PreAuthorize("@ss.hasPermi('system:recognition:add')")
    @Log(title = "花卉识别结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizRecognition bizRecognition)
    {
        return toAjax(bizRecognitionService.insertBizRecognition(bizRecognition));
    }

    /**
     * 修改花卉识别结果
     */
    @PreAuthorize("@ss.hasPermi('system:recognition:edit')")
    @Log(title = "花卉识别结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizRecognition bizRecognition)
    {
        return toAjax(bizRecognitionService.updateBizRecognition(bizRecognition));
    }

    /**
     * 删除花卉识别结果
     */
    @PreAuthorize("@ss.hasPermi('system:recognition:remove')")
    @Log(title = "花卉识别结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(bizRecognitionService.deleteBizRecognitionByIds(ids));
    }
}
